{config_load file="global.conf"}
{config_load file="_form_calc_result.conf" section="`$lang`"}

<h2>{if $isMAP}{#_form_calc_result__titleMain2#}{else}{#_form_calc_result__titleMain#}{/if}{*Calculation Results*}</h2>
<table border="0">
<tr
{if $isMAP}
style="display:none"
{/if}
>
    <td>
    {if $currPair!=1}
	<a href="javascript:void(null);" onClick="javascript:submitCalcAllForm();">{#_form_calc_result__msgAll#}{*ALL*}</a>
	{else}
	{#_form_calc_result__msgAll#}{*ALL*}
	{/if}
	{foreach item="itr" from=$selPairs}
	{section start=0 step=1 name=pair loop=$pairs}

            {if $itr==$pairs[pair].TradeID}
            {if $currPair!=$itr}
          	&nbsp;|&nbsp;<a href='javascript:void(null);' onClick='javascript:Calculate("pair",{$pairs[pair].TradeID});'>{$pairs[pair].Pair}</a>
          	{else}
          	&nbsp;|&nbsp;{$pairs[pair].Pair}
          	{/if}
			{/if}

 	{/section}
 	{/foreach}
	</td>
</tr>
</table>
 <hr>
<br>
 <table border="0" cellpadding="1" width="630" cellspacing="1" bgcolor="#ffffff">
<tr>
    <td width="110" align="left"><nobr>{#_form_calc_result__labelDeposit#}{*Initial Deposit:*}</nobr></td>
    <td width="5">&nbsp;</td>
    <td width="150" class="theader2">${$deposit}</td>
    <td width="10">&nbsp;</td>
    <td width="330" rowspan="8" align="right" valign="center">
        <img width="330" height="200" src="/profitplot.php?t={$smarty.now}" class="balance_graph">
    </td>
</tr>

<tr>
    <td><nobr>{#_form_calc_result__labelTotalProfit#}{*Total Profit:*}</nobr></td>
    <td>&nbsp;</td>
    <td class="theader2"><nobr>{$totals.profit100}% [${$totals.profit}; {$totals.pips} {#_form_calc_result__msgPips#}]</nobr></td>
    <td>&nbsp;</td>
</tr>

<tr style="display:none">
    <td><nobr>{#_form_calc_result__labelTotalPips#}{*Total Pips:*}</nobr></td>
    <td>&nbsp;</td>
    <td class="theader2">{$totals.pips}</td>
    <td>&nbsp;</td>
</tr>

<tr>
    <td><nobr>{#_form_calc_result__labelAnnual#}{*Annual Return:*}</nobr></td>
    <td>&nbsp;</td>
    <td class="theader2">{$totals.arr}%</td>
    <td>&nbsp;</td>
</tr>

<tr>
    <td><nobr>{#_form_calc_result__labelMonthly#}{*Annual Return:*}</nobr></td>
    <td>&nbsp;</td>
    <td class="theader2">{$totals.mrr}%</td>
    <td>&nbsp;</td>
</tr>


<tr>
    <td align="left">{#_form_calc_result__labelDrawdown#}{*Maximal drawdown:*}</td>
    <td>&nbsp;</td>
    <td class="theader2"><nobr><nobr>{$totals.ddown100}% [{$totals.ddown}; {$totals.ddownpips} {#_form_calc_result__msgPips#}{*pips*}]
    <span class="tip" onmouseover="tooltip(tooltip_dd);" onmouseout="exit();"><img src="{#images_dir#}/hint_bulb.gif" /></nobr></span></nobr>
    <td>&nbsp;</td>
</tr>

<tr>
    <td><nobr>{#_form_calc_result__labelTrades#}{*Trades:*}</nobr></td>
    <td>&nbsp;</td>
    <td class="theader2">{$totals.wTrades+$totals.lTrades}</td>
    <td>&nbsp;</td>
</tr>

<tr>
    <td>{#_form_calc_result__labelWinTrades#}{*Win Trades:*}</td>
    <td>&nbsp;</td>
    <td class="theader2">{$totals.wTrades}&nbsp;&nbsp;({$totals.wTrades1}%)</td>
    <td>&nbsp;</td>
</tr>

<tr>
    <td valign="top">{#_form_calc_result__labelLoss#}{*Loss Trades:*}</td>
    <td>&nbsp;</td>
    <td class="theader2" valign="top">{$totals.lTrades}&nbsp;&nbsp;({$totals.lTrades1}%)</td>
    <td>&nbsp;</td>
</tr>

</table>
<br>
    <img width="630" height="300" src="/calcplot.php?t={$smarty.now}&mode={$detalisation}" class="balance_graph">

<br><br>
 <table border="0" cellpadding="2" cellspacing="1" bgcolor="#ffffff">
 <tr>
    <td width="70" class="theader">{#_form_calc_result__labelMonth#}{*Month*}</td>
    <td width="70" class="theader" align="right">{#_form_calc_result__labelPips#}{*Pips*}</td>
    <td width="90" class="theader" align="right">{#_form_calc_result__labelProfit#}{*Profit*}</td>
    <td width="90" class="theader" align="right">%</td>
    <td width="100" class="theader" align="right">{#_form_calc_result__labelBalance#}{*Balance*}</td>
 </tr>

 <tr>
	<td
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>{#_form_calc_result__labelStart#}{*Start*}</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>&nbsp;--&nbsp;</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>&nbsp;--&nbsp;</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>&nbsp;--&nbsp;</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>${$deposit}</td>
</tr>

{foreach key="ktr" name="total" item="itr" from=$statsArr}
<tr>
	<td
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>{$itr.date}</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>{$itr.pips}</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>${$itr.profit|number_format}</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>{$itr.profit100|number_format:2}%</td>
	<td  align="right"
	{if $smarty.foreach.total.iteration%2==0}
	 class="darkRow"
	{/if}
	>${$itr.tbalance|number_format}{* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$itr.diffbalance} - {$itr.reinvestBalance} - {$itr.lotsize}*}</td>
</tr>
{/foreach}

<tr>
	<td class="theader">{#_form_calc_result__labelTotal#}{*Total*}</td>
	<td class="theader" align="right">{$totals.pips}</td>
	<td class="theader" align="right">${$totals.profit}</td>
	<td class="theader" align="right">{$totals.profit100}%</td>
	<td class="theader" align="right">${$totals.balance}</td>
</tr>
</table>
 <br>



{if $test}
<br><br>
<table border="0">

{section name=fcast loop=$test}
<tr>
	<td>{$test[fcast]}</td>
</tr>
{/section}
</table>

{/if}



{if $fcasts}
<br><br>
<table border="0">
    <tr>
    <td width="100" class="theader">{#_form_calc_result__labelMonth2#}{*Month*}</td>
    <td width="70" class="theader">{#_form_calc_result__labelPips2#}{*Pips*}</td>
    <td width="130" class="theader">{#_form_calc_result__labelProfit2#}{*Profit*}</td>
    <td width="130" class="theader">{#_form_calc_result__labelBalanceDiffPips#}{*Balance / Diff / Pips*}</td>
    <td class="theader">Debug</td>
    </tr>
{section name=fcast loop=$fcasts}
<tr>
	<td>{$fcasts[fcast].date}</td>
	<td>{$fcasts[fcast].pip}</td>
	<td>{$fcasts[fcast].profit}</td>
	<td>{$fcasts[fcast].balance} / {$fcasts[fcast].diffBalance} / {$fcasts[fcast].diffPips}</td>
	<td>{$fcasts[fcast].beginPrice} - {$fcasts[fcast].closePrice} => {$fcasts[fcast].caption}/{$fcasts[fcast].TradeID}
	<br>spr-{$fcasts[fcast].Spread}; pSize-{$fcasts[fcast].pipSize}; side-{$fcasts[fcast].side}; slp-{$fcasts[fcast].slippage}
	<span {if $fcasts[fcast].reinvestBalance==0}style="font-weight: bold"{/if} >
	<br>{$fcasts[fcast].lot} ({$fcasts[fcast].lotSet}); reinvest {$fcasts[fcast].reinvestBalance}
	<br>{$fcasts[fcast].contractAmount} - {$fcasts[fcast].contract}
	<span></td>
</tr>
{/section}
</table>

{/if}


{*
///////////////////////////////////////////////
debug cycles

{section name=item loop=$spreads}
	{$spreads[item]}&nbsp;
{/section}
         <br><b>Graph Array</b><br>


 {section name=item loop=$sess}
 	{foreach item="itr" from=$sess[item]}
		{$itr}&nbsp;
	{/foreach}
	<br>
{/section}

      sdsds {$test}
{php}
     echo time();
{/php}



{section name=item loop=$fdetails.data.date}
	{$fdetails.data.date[item]}/
	<br>
{/section}

{section name=item loop=$fdetails.data.balance}
	{$fdetails.data.balance[item]}/
	<br>
{/section}


 {section name=item loop=$weeks.data.balance}
 	{$weeks.data.balance[item]}
	<br>
{/section}


{php}
  echo intval(date("Y-W",1110000000));
{/php}


{section name=item loop=$fdetails.data.date}
	{$fdetails.data.date[item]|date_format}
	<br>
{/section}

//////////////////////////////////////////////
*}
